home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ian & Stuart's Australian Mac 1993 September
/
clonecd
/
September 93.img
/
Archives
/
Fun, Tricks & Hacks
/
IQ Test
/
IQ Test Sorce Code ƒ
/
DoWarningDialog.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-02-17
|
3KB
|
131 lines
#include "IQ Test.h"
/*
Function prototypes.
*/
static void OutlineButton(
ControlHandle button );
static pascal void StandardDrawDefaultOutline(
DialogPtr theDialog,
short itemNo );
short DoWarningDialog( void )
{
short itemHit,
itemType,
status = noErr;
Boolean dialogDone = FALSE;
DialogPtr theDialog;
Handle itemHandle;
Rect itemRect,
outlineRect;
dialogDone = FALSE;
theDialog = GetNewDialog( WARNING_DLOG_ID, NIL_PTR, MOVE_TO_FRONT );
GetDItem( theDialog, WARNING_QUIT_BUTTON, &itemType, &itemHandle,
&outlineRect );
InsetRect( &outlineRect, OUTLINE_FRAME_INSET, OUTLINE_FRAME_INSET);
GetDItem( theDialog, WARNING_OUTLINE_ITEM, &itemType, &itemHandle,
&itemRect );
SetDItem( theDialog, WARNING_OUTLINE_ITEM, itemType,
( Handle ) StandardDrawDefaultOutline, &outlineRect );
CenterAsAlert( theDialog );
ShowWindow( theDialog );
SetCursor( &arrow );
while( dialogDone == FALSE )
{
ModalDialog( NIL_PTR, &itemHit );
switch( itemHit )
{
case WARNING_QUIT_BUTTON:
dialogDone = TRUE;
status = QUIT_STATUS;
break;
default:
dialogDone = TRUE;
status = noErr;
break;
}
}
DisposeDialog( theDialog );
return ( status );
}
#define BUTTON_FRAME_SIZE 3
#define BUTTON_OVAL 16
void OutlineButton(
ControlHandle button )
{
Rect theRect;
PenState curPen;
/*
This code was modified from Pascal code provided by:
Keith Rollin
Apple Computer, Inc.
Developer Technical Support
For the outline to be drawn correctly on updateEvts, the Rect of the
userItem must be set to the size of the Rect used to draw the
outline. This must be done before the dialog is drawn for the first
time. (A draw command is issued by the Dialog Manager only if the
update region of the window overlaps the Rect of the userItem.)
Use the following code to accomplish this:
#define OUTLINE_FRAME_INSET -4
short itemType;
DialogPtrt theDialog;
Handle itemHandle;
Rect itemRect,
outlineRect;
theDialog = GetNewDialog( DIALOG_ID, NIL_PTR, MOVE_TO_FRONT );
GetDItem( theDialog, DEFAULT_BUTTON, &itemType, &itemHandle,
&outlineRect );
InsetRect( &outlineRect, OUTLINE_FRAME_INSET, OUTLINE_FRAME_INSET );
GetDItem( theDialog, OUTLINE_USERITEM, &itemType, &itemHandle,
&itemRect );
SetDItem( theDialog, OUTLINE_USERITEM, &itemType,
( Handle ) StandardDrawDefaultOutline, &outlineRect );
*/
if ( button != NIL_PTR )
{
GetPenState( &curPen );
PenNormal();
theRect = ( **button ).contrlRect;
InsetRect( &theRect, OUTLINE_FRAME_INSET, OUTLINE_FRAME_INSET );
if ( ( **button ).contrlHilite == INACTIVE )
PenPat( gray );
else
PenPat( black );
PenSize( BUTTON_FRAME_SIZE, BUTTON_FRAME_SIZE );
FrameRoundRect( &theRect, BUTTON_OVAL, BUTTON_OVAL );
SetPenState( &curPen );
}
}
pascal void StandardDrawDefaultOutline(
DialogPtr theDialog,
short itemNo )
{
short itemType;
Handle itemHandle;
Rect itemRect;
GetDItem( theDialog, ok, &itemType, &itemHandle, &itemRect );
OutlineButton( ( ControlHandle ) itemHandle );
}